<?php
/**
 *
 * (model)
 */
namespace App\Models\SalesReport;

use Illuminate\Database\Eloquent\Model;
class PaymentClassify extends Model
{
    protected $table = 'sr_payment_classify';

    protected $guarded = [];

    public $timestamps = false;

    public static $_type = [
        1 => '数值',
        2 => '占比',
    ];

    public static $_field = [
        'sales_volume',
        'sales_amount_rmb',
        'refund_num',
        'refund_amount_rmb',
        't_purchase_price_rmb',
        't_shipment_price_rmb',
        'selling_fees_rmb',
        'fba_fees_rmb',
        'p_thfba_rmb',
        'ms_fee_rmb',
        'lts_fee_rmb',
        'p_icfee_rmb',
        'rm_fee_rmb',
        'rebates_rmb',
        'spend_rmb',
        'reimburse_rmb',
        'reimburse_os_rmb',
        'reimburse_profit_rmb',
        'ied_rmb',
        'rod_rmb',
        'cplan_fee_rmb',
        'vat_fee_rmb',
        'profit_rmb',
        'earning_rmb',
        'total_rmb',
    ];

    //核算月报，制成汇总报表时统一字段赋值
    public static function _getData($pd,$rateOdds = []): array
    {
        $data = [];
        foreach (self::$_field as $field) {
            $data[$field] = $pd->{$field};
        }
        if(!empty($rateOdds)){
            return $data + $rateOdds;
        }else{
            return $data;
        }
    }
}
